package com.qxy.hgz.rank.ui;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import com.google.android.material.tabs.TabLayout;
import com.qxy.hgz.R;
import com.qxy.hgz.databinding.ActivityRankListBinding;


public class RankListActivity extends AppCompatActivity {
    private ActivityRankListBinding binding;
    private FragmentManager manager;
    private FragmentTransaction transaction;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityRankListBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        if (getSupportActionBar() != null) {
            getSupportActionBar().hide();
        }
        manager = getSupportFragmentManager();
        transaction = manager.beginTransaction();
        transaction.replace(R.id.container_fragment,new movieFragment());
        transaction.commit();

        binding.set.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                FragmentTransaction transaction = manager.beginTransaction();
                if (tab.getPosition() == 0) {
                    transaction.replace(R.id.container_fragment,new movieFragment());
                }else if (tab.getPosition() == 1) {
                    transaction.replace(R.id.container_fragment,new tvFragment());
                }else if (tab.getPosition() == 2) {
                    transaction.replace(R.id.container_fragment,new varietyFragment());
                }
                transaction.commit();
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });

    }


}